<html>
<head>
<title>
DatabaseObject - Helma Javascript Reference
</title>

<meta http-equiv="Content-Script-Type" content="text/javascript">
<script src="scripts.js"></script>
<link rel="stylesheet" href="styles.css" media="screen" />
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
    <script type="text/javascript">_uacct = "UA-737027-2";urchinTracker();</script>
<style>
td {
    font-family: "Trebuchet MS", sans-serif; 
    font-size: 13px; 
    line-height:135%;
}
.columnheight {
    height: 1350px;
}
</style>
</head>
<body bgcolor="white">

<div class="frame">

<img class="home" onclick="location='http://dev.helma.org/'" src="helmaheader.gif" /><br />
<div class="lead">
    <p>Detailed reference of prototypes, properties and methods available in the <br />
    Javascript environment of your Helma web applications.</p>
</div>

<script> openbox('content') </script>


    <div class="content">
        <div class="docs">
        
            <!--
            <div class="sectionHead">Library: DatabaseObject.js</div>
            -->
            <div class="section overview">
            <!--
                <div class="itemTitle">
                    Overview
                </div>
            -->
                <div>   
                    <div class="desc">Default properties and methods of objects of the 
class Packages.helma.scripting.rhino.extensions.DatabaseObject.</div>
                    <div class="itemTags">
            <!--
                    <ul>
                        
                    
                    </ul>
            -->
                    </div>
                </div>
            </div>
            
            <!--
            <div class="sectionHead">Constructors</div>
            -->
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            <!--
            <div class="sectionHead">Namespaces</div>
            -->
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            <!--
            <div class="sectionHead">Properties</div>
            -->
            
            
            <div class="section object">
                <div class="itemTitle">
                    <a name="DatabaseObject"></a>
                    
                    <span class="deprecated"><del>
                    
                    
                        <i><span class="symbolname">DatabaseObject</span></i>
                    
                    </del>&nbsp;&nbsp;deprecated use helma.Database instead</span>
                </div>
                
                
                    <div class="desc">A DatabaseObject represents a connection to a relational database 
and is created using the global getDBConnection function. There 
is no constructor to instantiate these objects. 
<br /><br />
The Direct DB interface allows the developer to directly access 
relational databases defined in the db.properties file without 
going through the Helma object model layer.
<br /><br />
The string passed to the getDBConnection function must match one 
of the data sources being defined in [AppDir]/db.properties, or an 
error will be thrown. 
<br /><br />
Example:
<pre>var dbConnection = getDBConnection("db_source_name");
&nbsp;
var dbRowset = dbConnection.executeRetrieval("select title from dummy");
while (dbRowset.next())
&nbsp;&nbsp;res.writeln(dbRowset.getColumnItem("title"));
<br /><br />
var deletedRows = dbConnection.executeCommand("delete from foobar");
if(deletedRows){
&nbsp;&nbsp;res.writeln(deletedRows + " rows successfully deleted");
}</pre>
<br /><br />
See also the documentation of the global getDBConnection() method.</div>
                
                
                
                
                
                
                
                <div class="detailHead">see</div>
                <table class="params">
                
                    <tr><td class="type"><div class="see"><a href="http://adele.helma.org/download/helma/apidocs/api/helma/scripting/rhino/extensions/DatabaseObject.html">Packages.helma.scripting.rhino.extensions.DatabaseObject</a></div></td></tr>
                
                    <tr><td class="type"><div class="see"><a href="global.html#getDBConnection">global.getDBConnection</a></div></td></tr>
                
                    <tr><td class="type"><div class="see"><a href="DatabaseObject.html#DatabaseObject.RowSet">DatabaseObject.RowSet</a></div></td></tr>
                
                    <tr><td class="type"><div class="see"><a href="helma.Database.html#helma.Database">helma.Database</a></div></td></tr>
                
                </table>
                

                <!-- if test="symbol.properties.length">
                <div class="detailHead">properties</div>
                <table class="params">
                
                </table>
                </if -->
            </div>
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            <div class="section object">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet"></a>
                    
                    
                    
                        <i><a href="#DatabaseObject" class="type">DatabaseObject</a>.
                        <span class="symbolname">RowSet</span></i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Rowset object representing the results of a value 
returning database query initiated using the 
dbConnection.executeRetrieval method. There 
is no constructor to instantiate these objects. 
<br /><br />
In addition, the RowSet will return any column name property 
as its value, any index as the value of the corresponding column, 
and enumerate column names. The enumeration will only contain 
the column names, not any property added to the prototype or 
the object itself. However the internal names (valueOf, 
toString, length), the properties of the prototype (including 
the routines of the RowSetAccessprotocol) takes precedence over 
the name of columns when accessed as a property. The usage of 
indexed access or of the routine getColumnItemis therefore prefered.
<br /><br />
The RowSet string representation includes the SQL statement 
and its logical position if at start or at end.</div>
                
                
                
                
                
                
                
                <div class="detailHead">see</div>
                <table class="params">
                
                    <tr><td class="type"><div class="see"><a href="global.html#getDBConnection">global.getDBConnection</a></div></td></tr>
                
                    <tr><td class="type"><div class="see"><a href="dbConnection.html">dbConnection</a></div></td></tr>
                
                </table>
                

                <!-- if test="symbol.properties.length">
                <div class="detailHead">properties</div>
                <table class="params">
                
                </table>
                </if -->
            </div>
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            

            <!--
            <div class="sectionHead">Constructors</div>
            -->
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            <div class="sectionHead">Methods</div>
            
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.getLastError"></a>
                    
                    
                        <i><a href="#DatabaseObject" class="type">DatabaseObject</a>.
                        <span class="symbolname">getLastError</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Return the last error which occured when connecting or 
executing a statement, undefined if none.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            undefined if none
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.getMetaData"></a>
                    
                    
                        <i><a href="#DatabaseObject" class="type">DatabaseObject</a>.
                        <span class="symbolname">getMetaData</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Return the meta data attached to the connection.</div>
                

                
                
                
                
                
                
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.executeRetrieval"></a>
                    
                    
                        <i><a href="#DatabaseObject" class="type">DatabaseObject</a>.
                        <span class="symbolname">executeRetrieval</span>(<span class="signature">sqlString</span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Used to implement SELECT and other value returning statements. 
<br /><br />
Return a RowSet object implementing the RowsetAccess protocol 
if the request is successful. Returns false otherwise. Additional 
arguments are ignored, and data is always returned as a RowsetAccess. 
The cursor is positioned before the fist row. If false was returned, 
getLastError may be called on the database object to get the error 
information. Note that an error is generated (rather than returning a status) 
if the connection was not successful.</div>
                

                
                
                
                
                
                <div class="detailHead">parameters</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            sqlString
                        </td>
                        <td>
                            as String
                        </td> 
                    </tr>
                
                </table>
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            DatabaseObject.RowSet with the resulting rowset, or false in case of error
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.executeCommand"></a>
                    
                    
                        <i><a href="#DatabaseObject" class="type">DatabaseObject</a>.
                        <span class="symbolname">executeCommand</span>(<span class="signature">sqlString</span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Used to implement INSERT, UPDATE, ddl statements and other 
non value returning statements. 
<br /><br />
Returns the number of rows impacted if the request is successful. 
Returns false otherwise. If false was returned, getLastError may be 
called on the database object to get the error information. Note 
that an error is generated (rather than returning a status) if the 
connection was not successful.</div>
                

                
                
                
                
                
                <div class="detailHead">parameters</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            sqlString
                        </td>
                        <td>
                            as String
                        </td> 
                    </tr>
                
                </table>
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            Number of rows impacted if successful or false if error.
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet.next"></a>
                    
                    
                        <i><a href="#DatabaseObject.RowSet" class="type">DatabaseObject.RowSet</a>.
                        <span class="symbolname">next</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Get the next row of results, return true if there is a next row, 
false otherwise. Note that next must be called before the first 
row can be accesses.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            Boolean true if a next row exists else false
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet.hasMoreRows"></a>
                    
                    
                        <i><a href="#DatabaseObject.RowSet" class="type">DatabaseObject.RowSet</a>.
                        <span class="symbolname">hasMoreRows</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Optimistic view of the possibility that more rows are present.
<br /><br />
Currently only returns false if next returned false. It is 
possible to call this routine at any time.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            Boolean false if calling next() returned false
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet.getLastError"></a>
                    
                    
                        <i><a href="#DatabaseObject.RowSet" class="type">DatabaseObject.RowSet</a>.
                        <span class="symbolname">getLastError</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Return the last error which occured when connecting or executing a 
statement, null (which test as false) if none.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            last error or else null if none
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet.getMetaData"></a>
                    
                    
                        <i><a href="#DatabaseObject.RowSet" class="type">DatabaseObject.RowSet</a>.
                        <span class="symbolname">getMetaData</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Return the meta data attached to the row set.</div>
                

                
                
                
                
                
                
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet.getColumnCount"></a>
                    
                    
                        <i><a href="#DatabaseObject.RowSet" class="type">DatabaseObject.RowSet</a>.
                        <span class="symbolname">getColumnCount</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Get the number of columns of this result, identical to 
the length attribute. It is possible to call this 
routine before the first record is fetched.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            Number of colums
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet.getColumnName"></a>
                    
                    
                        <i><a href="#DatabaseObject.RowSet" class="type">DatabaseObject.RowSet</a>.
                        <span class="symbolname">getColumnName</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Get the name of a column, in a way which is always working. 
The names can be accessed as properties, but they are shadowed 
by the functions and properties of the RowSetAccess prototype object. 
It is possible to call this routine before the first record is fetched.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            String containing the name of a column
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet.getColumnDatatypeNumber"></a>
                    
                    
                        <i><a href="#DatabaseObject.RowSet" class="type">DatabaseObject.RowSet</a>.
                        <span class="symbolname">getColumnDatatypeNumber</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Get the number of the datatype associated with the column. 
See the jdbc documentation for details. It is possible to 
call this routine before the first record is fetched.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            Number of data-types associated with the column
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet.getColumnDatatypeName"></a>
                    
                    
                        <i><a href="#DatabaseObject.RowSet" class="type">DatabaseObject.RowSet</a>.
                        <span class="symbolname">getColumnDatatypeName</span>(<span class="signature"></span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Get the  name of the datatype associated with the column. 
See the jdbc documentation for details. Some database do 
not return a valid name, in that case undefined is returned. 
It is possible to call this routine before the first record is fetched.</div>
                

                
                
                
                
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            String containing the name of the data-type associated with the column
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
            <div class="section function">
                <div class="itemTitle">
                    <a name="DatabaseObject.RowSet.getColumnItem"></a>
                    
                    
                        <i><a href="#DatabaseObject.RowSet" class="type">DatabaseObject.RowSet</a>.
                        <span class="symbolname">getColumnItem</span>(<span class="signature">name</span>)</i>
                    
                    
                    
                </div>
                
                
                    <div class="desc">Get the value of a column by its name (the value can be accessed by 
number simply indexing them - this is not faster than by name for FESI). 
The proper value is returned even if the name is used for a property of 
the RowSetAccess protocol, as next or length. A record must be available 
(that is next must have been called at least once).</div>
                

                
                
                
                
                
                <div class="detailHead">parameters</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            String
                        </td>
                        <td>
                            name
                        </td>
                        <td>
                            as String, name of the column
                        </td> 
                    </tr>
                
                </table>
                
                
                
                <div class="detailHead">returns</div>
                <table class="params">
                
                    <tr>
                        <td class="type">
                            
                        </td>
                        <td>
                            value of a column
                        </td> 
                    </tr>
                
                </table>
                
                
                

                

            </div>
            
            
            
        </div>
    </div>
    <div class="finePrint">
    Fri, 05 Feb 2010 17:40:02 GMT.
    </div>

<script> closebox() </script>

<script> openbox('pageintro') </script>

    <h3>core framework</h3>
        <ul>            
            <li><a href="global.html">global</a></li>
            <li><a href="app.html">app (application)</a></li>
            <li><a href="req.html">req (request)</a></li>
            <li><a href="res.html">res (response)</a></li>
            <li><a href="session.html">session</a></li>
            <li><a href="global.html#path">path</a></li>
            <li><a href="global.html#root">root</a></li>
            <li><a href="HopObject.html">HopObject</a></li>
            <li><a href="User.html">User</a></li>
            <li><a href="File.html">File</a></li>
            <li><a href="FtpClient.html">FtpClient</a></li>
            <li><a href="Image.html">Image</a></li>
            <li><a href="Mail.html">Mail</a></li>
            <li><a href="global.html#Remote">Remote</a></li>
            <li><a href="Xml.html">Xml</a></li>
            <li><a href="DatabaseObject.html">DatabaseObject</a></li>
            <li><a href="MimePart.html">MimePart</a></li>
            <li><a href="Skin.html">Skin</a></li>
            <li><a href="global.html#Object.dontEnum">Object</a></li>
        </ul>
        
    <h3>optional modules</h3>
        <ul>            
            <li><a href="ArrayExtensions.html">Array extensions</a></li>
            <li><a href="DateExtensions.html">Date extensions</a></li>
            <li><a href="NumberExtensions.html">Number extensions</a></li>
            <li><a href="ObjectExtensions.html">Object extensions</a></li>
            <li><a href="StringExtensions.html">String extensions</a></li>
            <li><a href="HopObjectExtensions.html">HopObject extensions</a></li>
            <li><a href="GlobalMacros.html">global macros</a></li>
            <li><a href="MacroFilters.html">macro filters</a></li>
            <li><a href="JSON.html">JSON methods</a></li>
            <br />
            <li><a href="helma.Aspects.html">helma.Aspects</a></li>
            <li><a href="helma.Chart.html">helma.Chart</a></li>
            <li><a href="helma.Color.html">helma.Color</a></li>
            <li><a href="helma.Database.html">helma.Database</a></li>
            <li><a href="helma.File.html">helma.File</a></li>
            <li><a href="helma.Ftp.html">helma.Ftp</a></li>
            <li><a href="helma.Group.html">helma.Group</a></li>
            <li><a href="helma.Html.html">helma.Html</a></li>
            <li><a href="helma.Http.html">helma.Http</a></li>
            <li><a href="helma.Image.html">helma.Image</a></li>
            <li><a href="helma.Mail.html">helma.Mail</a></li>
            <li><a href="helma.Search.html">helma.Search</a></li>
            <li><a href="helma.Skin.html">helma.Skin</a></li>
            <li><a href="helma.Ssh.html">helma.Ssh</a></li>
            <li><a href="helma.Url.html">helma.Url</a></li>
            <li><a href="helma.Zip.html">helma.Zip</a></li>
            <br />
            <li><a href="jala.BitTorrent.html">jala.BitTorrent</a></li>
            <li><a href="jala.Captcha.html">jala.Captcha</a></li>
            <li><a href="jala.Date.html">jala.Date</a></li>
            <li><a href="jala.db.html">jala.db</a></li>
            <li><a href="jala.DnsClient.html">jala.DnsClient</a></li>
            <li><a href="jala.Form.html">jala.Form</a></li>
            <li><a href="jala.History.html">jala.History</a></li>
            <li><a href="jala.HopObjectExtensions.html">jala HopObject extensions</a></li>
            <li><a href="jala.HtmlDocument.html">jala.HtmlDocument</a></li>
            <li><a href="jala.I18n.html">jala.I18n</a></li>
            <li><a href="jala.ImageFilter.html">jala.ImageFilter</a></li>
            <li><a href="jala.IndexManager.html">jala.IndexManager</a></li>
            <li><a href="jala.ListRenderer.html">jala.ListRenderer</a></li>
            <li><a href="jala.Mp3.html">jala.Mp3</a></li>
            <li><a href="jala.PodcastWriter.html">jala.PodcastWriter</a></li>
            <li><a href="jala.RemoteContent.html">jala.RemoteContent</a></li>
            <li><a href="jala.Rss20Writer.html">jala.Rss20Writer</a></li>
            <li><a href="jala.Utilities.html">jala.Utilities</a></li>
            <li><a href="jala.XmlRpcRequest.html">jala.XmlRpcRequest</a></li>
            <li><a href="jala.XmlWriter.html">jala.XmlWriter</a></li>
        </ul>
    
    <h3>java libraries</h3>
        <ul>            
            <li><a href="http://www.docjar.org/">docjar search</a></li>
        </ul>

    <h3>properties files</h3>
        <ul>            
            <li><a href="http://dev.helma.org/docs/Properties+Files/apps.properties/">apps.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Properties+Files/app.properties/">app.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Properties+Files/server.properties/">server.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Properties+Files/db.properties/">db.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Properties+Files/class.properties/">class.properties</a></li>
            <li><a href="http://dev.helma.org/docs/Type.properties+Documentation/">type.properties</a></li>
         </ul>
    
<script> closebox() </script>

</div>
<br clear="all" /><br /><br />



</body>
</html>
